<template>
  <div id="app">
    <router-view />
    <div
      id="news"
      v-if="this.$route.path != '/custmoer'"
      @click="newsJump"
      @touchmove="move"
      :style="
        newsFlag
          ? {
              left: 'calc(' + left + 'px - 1.8rem)',
              top: 'calc(' + top + 'px - 1.8rem)',
            }
          : ''
      "
    >
      <i class="iconfont icon-14"></i>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      left: 0,
      top: 0,
      newsFlag: false,
    };
  },
  methods: {
    move(e) {
      this.newsFlag = true;
      if (e.touches[0].clientX <= 0) {
        this.left = 0;
      } else if (e.touches[0].clientX >= e.view.innerWidth) {
        this.left = e.view.innerWidth;
      } else {
        this.left = e.touches[0].clientX;
      }

      if (e.touches[0].clientY <= 0) {
        this.top = 0;
      } else if (e.touches[0].clientY >= e.view.innerHeight) {
        this.top = e.view.innerHeight;
      } else {
        this.top = e.touches[0].clientY;
      }
    },
    newsJump() {
      this.$router.push({ path: "/custmoer" });
    },
  },
};
</script>

<style lang="scss">
#news {
  width: 3.8rem;
  height: 3.8rem;
  border-radius: 50%;
  background: #007aff;
  position: fixed;
  bottom: 5rem;
  right: 0.65rem;
  text-align: center;
  line-height: 3.8rem;
  z-index: 100;

  i {
    font-size: 1.8rem;
    color: #fff;
  }
}
</style>
